import 'package:flutter/material.dart';
import 'package:nyh_motorcade_app/styles/colors.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

typedef GestureTapCallback = void Function();

class CustomAppBar extends AppBar {
  CustomAppBar({
    required BuildContext context,
    required String title,
    Color? textColor,
    Color? backgroundColor,
    bool automaticallyImplyLeading = true,
    double? titleSpacing,
    PreferredSizeWidget? bottom,
    List<Widget>? actions,
    GestureTapCallback? onTap,
  }) : super(
          elevation: 0,
          titleSpacing: titleSpacing ?? 0,
          backgroundColor: backgroundColor ?? Colours.color_white,
          automaticallyImplyLeading: automaticallyImplyLeading,
          centerTitle: false,
          title: Text(
            title,
            style: TextStyle(
              color: textColor ?? Colours.color_text_theme,
              fontSize: 20.sp,
              fontWeight: FontWeight.w500,
            ),
          ),
          leading: automaticallyImplyLeading
              ? IconButton(
                  icon: Image.asset(
                    "images/ic_back_arrow.png",
                  ),
                  onPressed: () {
                    if (onTap != null) {
                      onTap();
                    } else {
                      Navigator.pop(context);
                    }
                  },
                )
              : null,
          actions: actions,
          bottom: bottom,
        );
}
